<template>
  <div class="container">
    <el-form label-width="80px" size="small">
      <mavon-editor
        ref="mavonEditorRef"
        v-model="form.content"
        :ishljs="true"
        @imgAdd="imgAdd"
      />
    </el-form>
  </div>
</template>

<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue'

let form = reactive({
  content: '',
})

const mavonEditorRef = ref(null)

// 在组件挂载后访问mavonEditorRef
onMounted(() => {
  if (mavonEditorRef.value) {
    console.log(mavonEditorRef.value) // 这里你可以安全地访问组件实例
  }
})

const imgAdd = (pos: any, $file: any) => {
  const formData = new FormData()
  formData.append('file', $file)
}
</script>

<style scoped lang="scss">
.container {
  height: 500px;
}
</style>
